<!--
 * @Author: 秦福凯
 * @LastEditTime: 2025-02-17 11:42:33
 * @Description: 登录界面
-->
<template>
  <div class="u-login">
    <div class="login-box">
      <el-switch class="dark" v-model="globalStore.isDark" inline-prompt :active-icon="Sunny" :inactive-icon="Moon" @change="switchDark" />
      <div class="login-left">
        <img class="login-left-img" src="@/assets/img/login/login_left.png" alt="login" />
      </div>
      <div class="login-form">
        <div class="login-logo">
          <h2 class="logo-text">邮电校用户登录</h2>
        </div>
        <u-form :form="form" :element="formList"></u-form>
        <div class="login-btn">
          <el-button :icon="UserFilled" round size="large" type="primary" :loading="loading" @click="login">
            登录
          </el-button>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
  import { useGlobalStore } from "@/store/global"
	import {useTheme} from '@/hooks/useTheme.js'
  import { Sunny, Moon,UserFilled } from '@element-plus/icons-vue'
  import { useTabsStore } from "@/store/tabs"
  import { useRouter } from "vue-router"

  const useThemeMethod = useTheme();
  const globalStore = useGlobalStore();
  const tabsStore = useTabsStore();
  const router = useRouter()

  let loading = ref(false)
  let formList = reactive([
    {label:'账号:',type:'input',sp:24,lw:'70px',re:true,key:'acconut'},
    {label:'密码:',type:'password',sp:24,lw:'70px',re:true,key:'password'},
    {label:'验证码:',type:'yzm',key:'yzm',lw:'70px',sp:24,re:true,src:''},
  ])
  let form = reactive({
    yzms:'',
  })
  // 切换模式
  function switchDark(){
    useThemeMethod.switchDark()
  }
  function login(){
    tabsStore.clearTabs();
    router.push('/home');
  }
</script>

<style lang="scss">
  .u-login{
    height: 100vh;
    min-height: 550px;
    background-color: #eeeeee;
    background-image: url("@/assets/img/login/login_bg.svg");
    background-size: 100% 100%;
    background-size: cover;
    display: flex;
    align-items: center;
    justify-content: center;
    .login-box{
      position: relative;
      box-sizing: border-box;
      display: flex;
      align-items: center;
      justify-content: space-around;
      width: 96.5%;
      height: 94%;
      padding: 0 50px;
      background-color: rgb(255 255 255 / 80%);
      border-radius: 10px;
      .dark {
      position: absolute;
      top: 13px;
      right: 18px;
      }
      .login-left {
        width: 800px;
        margin-right: 10px;
        .login-left-img {
          width: 100%;
          height: 100%;
        }
     }
     .login-form {
      width: 420px;
      padding: 40px 40px 45px;
      background-color: var(--el-bg-color);
      border-radius: 10px;
      box-shadow: rgb(0 0 0 / 10%) 0 2px 10px 2px;
      .login-logo {
        display: flex;
        align-items: center;
        justify-content: center;
        margin-bottom: 45px;
        .login-icon {
          width: 60px;
          height: 52px;
        }
        .logo-text {
          padding: 0 0 0 25px;
          margin: 0;
          font-size: 24px;
          font-weight: bold;
          color: #34495e;
          white-space: nowrap;
        }
      }
      .el-form-item {
        margin-bottom: 40px;
      }
      .login-btn {
        display: flex;
        width: 100%;
        justify-content: center;
        .el-button {
          width: 90%
        }
      }
    }
    }
  }
</style>